package com.example.common.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.blankj.utilcode.util.ToastUtils
import com.gyf.immersionbar.ImmersionBar

abstract class BaseActivity <VDB : ViewDataBinding> : AppCompatActivity(){

    lateinit var mDataBinding : VDB
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mDataBinding=DataBindingUtil.setContentView(this,getLayoutId())
        //沉浸式状态栏
        ImmersionBar.with(this).fullScreen(true).init()
        //初始化组件
        initViews()

    }

    fun showToastMessage(msg : String){
        if (!msg.isNullOrEmpty()){
            ToastUtils.showLong(msg)
        }
    }


    abstract fun initViews()

    abstract fun getLayoutId(): Int

    open fun initData(){

    }
    open fun updateUI(){

    }

}